package com.health.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.health.R;

/**
 * 数据下载adapter
 * Created by Administrator on 2018/2/26 0026.
 */

public class DownloadGridViewAdapter extends BaseAdapter {

    private int[] imgs;
    private String[] names;
    private int[] colors;
    private Context mContext;


    public DownloadGridViewAdapter(Context mContext) {
        this.mContext = mContext;
        imgs = new int[] { R.drawable.download,R.drawable.download};
        names = new String[] { "高血压数据下载" ,"糖尿病数据下载"};
        colors = new int[] { 0xff404040,0xff404040};
    }

    @Override
    public int getCount() {
        return imgs.length;
    }

    @Override
    public Object getItem(int position) {
        return names[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;

        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.updata_menu_griditem, null);
            viewHolder.image = (ImageView) convertView.findViewById(R.id.norm_img);
            viewHolder.name = (TextView) convertView.findViewById(R.id.norm_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }


        viewHolder.image.setImageResource(imgs[position]);
        viewHolder.name.setText(names[position]);

        return convertView;
    }

    class ViewHolder {
        public TextView name;
        public ImageView image;
    }

}
